package com.cssl.controller;

import com.cssl.entity.User;
import com.cssl.service.UserService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Transactional
@RestController
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping("/addid")
    public Object addid(){
        User user =new User();
        //user.setId(20);
        user.setName("hzy");
        user.setPwd("987");
        user.setAddress("长沙");
        Object bl=userService.addid(user);
        return bl;
    }

    @RequestMapping("/delid")
    public boolean delid(){

        return userService.delid(20);
    }

    @RequestMapping("/findid/{id}")
    public User findid(@PathVariable int id){

        return userService.findid(id);
    }

    @RequestMapping("/show")
    public List<User> show(){

        return userService.show();
    }

    @RequestMapping("/add")
    public boolean add(){

        return userService.addval("hzy","wlp");
    }

    @RequestMapping("/del")
    public boolean del(){

        return userService.del("hzy");
    }
}
